﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AvalonDock;
using System.Collections.ObjectModel;
using System.Windows;
using QinTools.View;
using QinTools.Model.Characters;
using System.Windows.Input;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using QinTools.ViewModel.Documents;

namespace QinTools.ViewModel
{
    public class MainViewModel : ViewModelBase
    {
        #region Constructors
        static MainViewModel()
        {
            Instance = new MainViewModel();
        }
        private MainViewModel()
        {
            NewCharacterCommand = new RelayCommand(CreateNewCharacter);
            _Documents = new ObservableCollection<Document>();
            Documents = new ReadOnlyObservableCollection<Document>(_Documents);
        }
        #endregion
        #region Properties
        public static MainViewModel Instance { get; private set; }
        public ReadOnlyObservableCollection<Document> Documents { get; private set; }
        private ObservableCollection<Document> _Documents;
        #region CurrentDocument Notified Property
        private Document _CurrentDocument;
        public Document CurrentDocument
        {
            get
            {
                return _CurrentDocument;
            }
            set
            {
                _CurrentDocument = value;
                RaisePropertyChanged("CurrentDocument");
            }
        }
        #endregion

        #endregion
        #region Commands
        public ICommand NewCharacterCommand { get; private set; }
        #endregion
        #region Command Handlers
        private void CreateNewCharacter()
        {
            var vm = new CharacterViewModel(new Character());
            var doc = new CharacterDocument(vm);
            _Documents.Add(doc);
        }
        #endregion
    }
}
